Skip to content

build(tsconfig): scope type lib to Node 22 features - #151

Merged
stijnvanhulle merged 2 commits into
mainfrom
claude/dreamy-gates-lmbDZ
Jun 4, 2026
Merged

build(tsconfig): scope type lib to Node 22 features#151
stijnvanhulle merged 2 commits into
mainfrom
claude/dreamy-gates-lmbDZ

Conversation

@stijnvanhulle

Copy link
Copy Markdown
Owner

What

Bump target to ES2024 and set an explicit lib in configs/base.json so the TypeScript type library matches what Node 22 (V8 12.4) ships at runtime.

"target": "ES2024",
"lib": ["ES2024", "ES2025.Collection", "ES2025.Iterator", "ESNext.Array"]

Why

The project runs on Node 22 (CI and engines already pin it), but target was ES2022 with no lib, so the type library stopped at ES2022. Node 22 language built-ins did not typecheck even though they run fine. As the linked DefinitelyTyped discussion notes, language built-ins come from TypeScript's lib, not @types/node.

Feature to lib mapping (TypeScript 6.0.3):

Node 22 feature lib
toSorted / toReversed / with ES2023 (in ES2024)
Object.groupBy / Map.groupBy, Promise.withResolvers ES2024
Set methods (union / intersection / difference / …) ES2025.Collection
Iterator helpers (map / filter / take / toArray / …) ES2025.Iterator
Array.fromAsync ESNext.Array

Only Node 22, nothing beyond

The granular sublibs are deliberate. The full ES2025 lib would also pull in Float16Array (Node 24), and ESNext.Collection would pull in Map.getOrInsert (a Stage-3 proposal, not in Node 22). Both are excluded by this config. Verified:

  • All six features above typecheck.
  • new Float16Array(2)error TS2304: Cannot find name 'Float16Array'.
  • new Map().getOrInsert("a", 1)error TS2550: Property 'getOrInsert' does not exist.

Verify

pnpm typecheck && pnpm test

Both pass; pnpm format and pnpm lint are clean.

Ref: DefinitelyTyped/DefinitelyTyped#74504

https://claude.ai/code/session_01PazNrvKYZSS5eYu9DUGurf


Generated by Claude Code

Bump target to ES2024 and set an explicit lib so the TypeScript type
library matches what Node 22 (V8 12.4) ships at runtime: Object.groupBy /
Map.groupBy and Promise.withResolvers (ES2024), Set methods and iterator
helpers (ES2025 Collection/Iterator sublibs), and Array.fromAsync
(ESNext.Array). Granular sublibs are used on purpose so Float16Array,
which is Node 24, stays out.

https://claude.ai/code/session_01PazNrvKYZSS5eYu9DUGurf
@codesandbox

codesandbox Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@pkg-pr-new

pkg-pr-new Bot commented Jun 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/stijnvanhulle/template/@stijnvanhulle/template-core@151
npm i https://pkg.pr.new/stijnvanhulle/template/@stijnvanhulle/template-demo@151

commit: ec3b87f

@stijnvanhulle
stijnvanhulle merged commit 52b392f into main Jun 4, 2026
9 checks passed
@stijnvanhulle
stijnvanhulle deleted the claude/dreamy-gates-lmbDZ branch June 4, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants